/**
 * Copyright (C) 2018-2019
 * All rights reserved, Designed By www.joolun.com
 * 注意：
 * 本软件为www.joolun.com开发研制，项目使用请保留此说明
 */
const app = getApp()

Page({
  data: {
    config: app.globalData.config,
    wxUser: null,
    userInfo: null,
    genders: [{
      name: "未知",
      value: "2"
    }, {
      name: "男",
      value: "0"
    }, {
      name: "女",
      value: "1"
    }] 
  },
  onShow(){   
    let wxUser = app.globalData.wxUser
    this.setData({
      wxUser: wxUser
    })
    this.wxUserGet()
  },
  onLoad(){
    
  },
  getUserProfile(e) {
    wx.getUserProfile({
      desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
      success: (detail) => {
        app.api.wxUserSave(detail)
        .then(res => {
          let wxUser = res.data
          this.setData({
            wxUser: wxUser
          })
          app.globalData.wxUser = wxUser
          this.wxUserGet()
        })
      }
    })
  },
  //获取商城用户信息
  wxUserGet(){
    app.api.wxUserGet()
      .then(res => {
        console.log(res.data)
        this.setData({
          userInfo: res.data
        })
        console.log(this.data.userInfo)
      })
  }
})
